<input hidden="hidden" id="navValue" value="等级设置">

<div class="page-content">
    <div class="page-header">
        <h1>
            系统设置
            <small>
                <i class="ace-icon fa fa-angle-double-right"></i>
                股东等级设置
            </small>
        </h1>
    </div><!-- /.page-header -->

    <div class="row">
        <div class="col-xs-12">
            <table id="simple-table" class="table  table-bordered table-hover">
                <thead>
                <tr>
                    <th class="center">等级</th>
                    <th class="center">称号</th>
                    <th class="center">股份</th>
                    <th class="center">操作</th>
                </tr>
                </thead>

                <tbody>
                {volist name="$c" id="con"}
                <tr  class="center">
                    <td>{$con['level']}</td>
                    <td><input type="text" id="name_{$con['level']}" name="name_{$con['level']}" value='{$con['name']}' readonly></td>
                    <td><input type="text" id="shares_{$con['level']}" name="shares_{$con['level']}" value='{$con['performance']}' readonly></td>
                    <td>
                        <span id="edit_{$con['level']}" >
                        <button class="btn btn-xs btn-warning" value="{$con['level']}" onclick="edit(this);">
                            <i class="ace-icon fa fa-pencil bigger-120"></i>
                        </button>
                        </span>
                        <span id="check_{$con['level']}" style="display: none">
                        <button class="btn btn-xs btn-success" value="{$con['level']}"  onclick="check(this);">
                            <i class="ace-icon fa fa-check bigger-120"></i>
                        </button>
                        </span>
                    </td>
                </tr>
                {/volist}
                </tbody>
            </table>
        </div><!-- /.span -->
    </div><!-- /.row -->
</div>
<script type="text/javascript">
    function edit(obj){
        $("#edit_"+$(obj).val()).css("display",'none');
        $("#check_"+$(obj).val()).css("display",'block');
        $("#name_"+$(obj).val()).removeAttr("readonly");
        $("#shares_"+$(obj).val()).removeAttr("readonly");
    }

    function check(obj){
        var val = $(obj).val();
        $("#edit_"+val).css("display",'block');
        $("#check_"+val).css("display",'none');
        $("#name_"+val).attr("readonly","readonly");
        $("#shares_"+val).attr("readonly","readonly");
        $.ajax({
            type: "get",
            url: "{:url('levelSet')}",
            data: {name:$("#name_"+val).val(), performance:$("#shares_"+val).val(),level:val},
            dataType: "json",
            success: function(data){
                console.log(data);
                if(data == 'success'){
                    layer.msg('修改成功');
                }else{
                    layer.msg('修改失败');
                }
            }
        });
    }
</script>
